    function Login(options){
        this.btn = options.btn
        this.user = options.user
        this.pass = options.pass
        this.msg = options.msg
        this.url = options.url

        this.type = Math.random();

        this.init()
    }
    Login.prototype.init = function(){
        var that = this;
        this.btn.onclick = function(){
            that.load()
        }
    }
    Login.prototype.load = function(){
        var that = this;
        ajaxPost(this.url,{
            username:this.user.value,
            password:this.pass.value
        }).then(function(res){
                    console.log(JSON.parse(res))
                     
                    if(JSON.parse(res).msg == "登录成功"){
                        that.msg.innerHTML = JSON.parse(res).msg;
                        setTimeout(function(){
                            window.location.href="index.html";
                        },1000)
                    }
                    
           
        },function(code){
            console.log(code,"前端的ajax请求失败，有可能是网络原因或接口错误，或服务器问题，反正不一定是登录失败")
        })
    }
    new Login({
        btn:document.getElementById("btn"),
        user:document.getElementById("user"),
        pass:document.getElementById("pass"),
        msg:document.getElementById("msg"),
        url:"/api/login"
    })